package hu.vaes_dot_hrak.szoftlab4.gui;

import hu.vaes_dot_hrak.szoftlab4.Ant;
import hu.vaes_dot_hrak.szoftlab4.FieldElement;

import java.awt.geom.Point2D;
import java.util.List;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

public class FieldElementView extends JPanel implements Viewable {

	protected int WIDTH = 30;
	protected int HEIGHT = 30;
	private Point2D coordinates;
	private ImageIcon image;

	private FieldElement fieldElement;

	private List<FieldElement> elements;

	public FieldElementView(FieldElement fieldElement) {
		this.fieldElement = fieldElement;
	}

	public FieldElementView(List<FieldElement> elements, Point2D coordinates) {
		// TODO Auto-generated constructor stub
		this.elements = elements;
		this.coordinates = coordinates;

		update();
	}

	public int getWIDTH() {
		return WIDTH;
	}

	public int getHEIGHT() {
		return HEIGHT;
	}

	@Override
	public void update() {
		// TODO Auto-generated method stub
		for (int i = 0; i < elements.size(); i++) {
			if (elements.get(i) != null) {
				if (elements.get(i).getClass().equals(Ant.class)) {
					AntView antView = new AntView((Ant) elements.get(i));
					this.add(antView);
					antView.setLocation((int) coordinates.getX(), (int) coordinates.getY());

				}
			}
		}
	}

	public Point2D getCoordinates() {
		return coordinates;
	}

	public void setCoordinates(Point2D coordinates) {
		this.coordinates = coordinates;
	}

	public void addViewable(Viewable v) {
	}

}
